<?php

	defined('BASEPATH') or die('forbidden');
	
	class PassWordReset_Controller Extends Controller {
		private $wholeServerHost;
		private $platformlist;
		
	    function _init() {
	        check_level(50, segment(0), segment(1), segment(2, 'index'));
	        $config = get_config();
	        $this->wholeServerHost = $config['host_url'];
	        $tmpconn = $this->load->database('center_db') or die("load failed".mysql_error());
	        $tmpconn->query("select distinct platform from account") or die("query failed".mysql_error());
	        while ($n = $tmpconn->get_array())
	        {
	        	$this->platformlist[] = $n['platform'];
	        }
	    }
	    
		function index()
		{
			if (is_submit ()) {
			$rowdata = $_POST ['row'];
			// print_r($rowdata);
			// exit(0);
			$rowdata ['platform'] = $this->platformlist [$rowdata ['platform']];
			$str = array_to_stringparam ( $rowdata );
			$str = $this->wholeServerHost . $str . "action=18";
			//print_r ( $str );
			//exit ( 0 );
			$strResult = vpost ( $str, 5 );
			
			$result = 0;
			// 操作失败或者连接失败
			if ($strResult != '0' || $strResult === FALSE) {
				$result = 1;
				unset ( $rowdata );
				if ($strResult == '2') {
					echo "<script>alert('" . translate ( 'NO_ACCOUNTNAME' ) . "')</script>";
				} else {
					echo "<script>alert('" . translate ( 'C_TIPS_ERROR_TEXT' ) . "')</script>";
				}
			} else {
				insert_log ( translate ( 'MENU_SEAL_PASSWORDRESET' ), translate ( 'RESET' ), NULL, array (
						"name" => $rowdata ['account'] 
				) );
				echo "<script>alert('" . translate ( 'C_TIPS_SUCCESS_TEXT' ) . "')</script>";
			}
		}
			$data['row']=$rowdata;
			$this->view->assign("platform", $this->form->select("row[platform]", $this->platformlist, '',array('id' => 'platform')));
			$this->view->display("seal/passwordreset/index", $data);
		}
	}
?>